package com.tdkj.model.shop;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.tdkj.model.base.BaseEntity;
import com.tdkj.model.common.BeanType;
import com.tdkj.model.risevalue.BeanFloatColorCustom;
import com.tdkj.model.user.BeanUser;

/**
 * 
 */
@Entity
@Table(name = "shop_good")
public class BeanGood extends BaseEntity {


	//类型
	private BeanType type;
	
	//出售类型，0 1
	private Integer sellType;
	
	//使用情况
	private Integer useType;
	
	private String code;
	private String name;
	private BigDecimal price;
	//加价幅度
	private BigDecimal rateOfIncrease;
	private Integer quantity;
	
	private String imgurl;
	
	private Integer color;
	
	private BeanFloatColorCustom custom;
	
	private String keywords;
	
	private String detailDescription;
	
	private String state;
	
	//未提交审核，未审核，审核通过，审核未通过, -1,0,1,2
	private String auditState;
	
	private BeanUser user; 
	
	private BeanShelf shelf;
	
	private BeanShop shop;
	
	private BeanGoodLogisticsInfo logisticsInfo ;
	
	private Map<String, String> properties;
	
	private List<BeanGoodSnapshot> snapshots;
	
	//提交审核时间
	private Timestamp submitTime;
	//发布时间
	private Timestamp publishTime;
	
	private BeanGoodShowcase showcase;
	
	private List<BeanGoodAuction> auctions;
	
	private BeanGoodAuction currentAuction;
	
	private Integer inventory;
	
	//店铺内的商品分类
	private BeanType innerType;
	
	
	//other
	//有效期
	private Integer effective;
	//发票
	private Boolean invoice;
	//保修
	private Boolean warranty;
	//自动重发
	private Boolean automaticRepeat;
	
	//访问统计
	private Integer visitCount;

	// Constructors

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public BigDecimal getPrice() {
		return this.price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getImgurl() {
		return this.imgurl;
	}

	public void setImgurl(String imgurl) {
		this.imgurl = imgurl;
	}

	/**
	 * @return the user
	 */
	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="user_id")
	public BeanUser getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(BeanUser user) {
		this.user = user;
	}

	/**
	 * @return the type
	 */
	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="type_id")
	public BeanType getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(BeanType type) {
		this.type = type;
	}

	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="shelf_id")
	public BeanShelf getShelf() {
		return shelf;
	}

	/**
	 * @param shelf the shelf to set
	 */
	public void setShelf(BeanShelf shelf) {
		this.shelf = shelf;
	}

	/**
	 * @return the sellType
	 */
	public Integer getSellType() {
		return sellType;
	}

	/**
	 * @param sellType the sellType to set
	 */
	public void setSellType(Integer sellType) {
		this.sellType = sellType;
	}

	/**
	 * @return the useType
	 */
	public Integer getUseType() {
		return useType;
	}

	/**
	 * @param useType the useType to set
	 */
	public void setUseType(Integer useType) {
		this.useType = useType;
	}

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return the quantity
	 */
	public Integer getQuantity() {
		return quantity;
	}

	/**
	 * @param quantity the quantity to set
	 */
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	/**
	 * @return the rateOfIncrease
	 */
	public BigDecimal getRateOfIncrease() {
		return rateOfIncrease;
	}

	/**
	 * @param rateOfIncrease the rateOfIncrease to set
	 */
	public void setRateOfIncrease(BigDecimal rateOfIncrease) {
		this.rateOfIncrease = rateOfIncrease;
	}

	/**
	 * @return the ticketcolor
	 */

	/**
	 * @return the color
	 */
	public Integer getColor() {
		return color;
	}

	/**
	 * @param color the color to set
	 */
	public void setColor(Integer color) {
		this.color = color;
	}

	/**
	 * @return the custom
	 */
	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="ticketcolor_custom_id")
	public BeanFloatColorCustom getCustom() {
		return custom;
	}

	/**
	 * @param custom the custom to set
	 */
	public void setCustom(BeanFloatColorCustom custom) {
		this.custom = custom;
	}

	/**
	 * @return the keywords
	 */
	public String getKeywords() {
		return keywords;
	}

	/**
	 * @param keywords the keywords to set
	 */
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	/**
	 * @return the detailDescription
	 */
	public String getDetailDescription() {
		return detailDescription;
	}

	/**
	 * @param detailDescription the detailDescription to set
	 */
	public void setDetailDescription(String detailDescription) {
		this.detailDescription = detailDescription;
	}

	/**
	 * @return the logisticsInfo
	 */
	@OneToOne(fetch=FetchType.LAZY, cascade={CascadeType.ALL})
	@JoinColumn(name="logistics_info_id")
	public BeanGoodLogisticsInfo getLogisticsInfo() {
		return logisticsInfo;
	}

	/**
	 * @param logisticsInfo the logisticsInfo to set
	 */
	public void setLogisticsInfo(BeanGoodLogisticsInfo logisticsInfo) {
		this.logisticsInfo = logisticsInfo;
	}
	
	@ElementCollection
	@CollectionTable(name="shop_good_properties",joinColumns={@JoinColumn(name="good_id",referencedColumnName="id")})
	@MapKeyColumn(name="_key")
	@Column(name="_value")
	public Map<String, String> getProperties() {
		return properties;
	}
	/**
	 * @param positionProperties the positionProperties to set
	 */
	public void setProperties(Map<String, String> properties) {
		this.properties = properties;
	}

	/**
	 * @return the snapshot
	 */
	@OneToMany(fetch=FetchType.LAZY, mappedBy="good")
	public List<BeanGoodSnapshot> getSnapshots() {
		return snapshots;
	}

	/**
	 * @param snapshot the snapshot to set
	 */
	public void setSnapshots(List<BeanGoodSnapshot> snapshots) {
		this.snapshots = snapshots;
	}

	/**
	 * @return the publishTime
	 */
	public Timestamp getPublishTime() {
		return publishTime;
	}

	/**
	 * @param publishTime the publishTime to set
	 */
	public void setPublishTime(Timestamp publishTime) {
		this.publishTime = publishTime;
	}

	/**
	 * @return the showcase
	 */
	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="showcase_id")
	public BeanGoodShowcase getShowcase() {
		return showcase;
	}

	/**
	 * @param showcase the showcase to set
	 */
	public void setShowcase(BeanGoodShowcase showcase) {
		this.showcase = showcase;
	}

	/**
	 * @return the shop
	 */
	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="shop_id")
	public BeanShop getShop() {
		return shop;
	}

	/**
	 * @param shop the shop to set
	 */
	public void setShop(BeanShop shop) {
		this.shop = shop;
	}

	/**
	 * @return the auction
	 */
	@OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH}, mappedBy="good")
	public List<BeanGoodAuction> getAuctions() {
		return auctions;
	}

	/**
	 * @param auction the auction to set
	 */
	public void setAuctions(List<BeanGoodAuction> auctions) {
		this.auctions = auctions;
	}


	public String getAuditState() {
		return auditState;
	}

	/**
	 * @param auditState the auditState to set
	 */
	public void setAuditState(String auditState) {
		this.auditState = auditState;
	}

	/**
	 * @return the inventory
	 */
	public Integer getInventory() {
		return inventory;
	}

	/**
	 * @param inventory the inventory to set
	 */
	public void setInventory(Integer inventory) {
		this.inventory = inventory;
	}

	@ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
	@JoinColumn(name="inner_type_id")
	public BeanType getInnerType() {
		return innerType;
	}

	public void setInnerType(BeanType innerType) {
		this.innerType = innerType;
	}

	public Integer getEffective() {
		return effective;
	}

	public void setEffective(Integer effective) {
		this.effective = effective;
	}

	public Boolean getInvoice() {
		return invoice;
	}

	public void setInvoice(Boolean invoice) {
		this.invoice = invoice;
	}

	public Boolean getWarranty() {
		return warranty;
	}

	public void setWarranty(Boolean warranty) {
		this.warranty = warranty;
	}

	public Boolean getAutomaticRepeat() {
		return automaticRepeat;
	}

	public void setAutomaticRepeat(Boolean automaticRepeat) {
		this.automaticRepeat = automaticRepeat;
	}

	@OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH})
	@JoinColumn(name="current_auction_id")
	public BeanGoodAuction getCurrentAuction() {
		return currentAuction;
	}

	public void setCurrentAuction(BeanGoodAuction currentAuction) {
		this.currentAuction = currentAuction;
	}

	public Integer getVisitCount() {
		return visitCount;
	}

	public void setVisitCount(Integer visitCount) {
		this.visitCount = visitCount;
	}

	public Timestamp getSubmitTime() {
		return submitTime;
	}

	public void setSubmitTime(Timestamp submitTime) {
		this.submitTime = submitTime;
	}
	
	
}